const app = getApp()
Page({
  data: {
    domainName: app.domainName,
    navActive:{1:'',2:'',3:'active'},
    navShow:{1:'hide',2:'hide',3:''},
    shenList:[],
    qiuList:[],
    sshiData:[],
    duiname:''
  },
  onLoad() {
      var _this=this;
      this.getShenQing();
      wx.request({
        url: app.domainName + 'web/?c=getzhanduiname',
        method: 'POST',
        data: {openid:app.globalData.openid}, header: { 'content-type': 'application/x-www-form-urlencoded' },
        success: function (res) {
             _this.setData({duiname:res.data.n})
        }});
  },
  chNav(e){
    var _this=this;
    var _id=e.currentTarget.dataset.id;
    var _navActive={1:'',2:'',3:''};
    var _navShow={1:'hide',2:'hide',3:'hide'};
    _navShow[_id]='';
    _navActive[_id]='active';
    this.setData({navActive:_navActive, navShow:_navShow});
    if(2 == _id){
      this.getQiuYuan();
    }
    if(3 == _id){
      this.getShenQing();
    }
    if(1 == _id){
      wx.request({
        url: app.domainName + 'web/?c=getsyulan',
        method: 'POST',
        data: {openid:app.globalData.openid}, header: { 'content-type': 'application/x-www-form-urlencoded' },
        success: function (res) {
             _this.setData({sshiData:res.data.d})
        }});
    }
    console.log(_id);
  },
  gome(){
    wx.redirectTo({url: '/pages/zdui/index'})
  },
  getShenQing(){
    var _this=this;
    wx.request({
      url: app.domainName + 'web/?c=getshenqing',
      method: 'POST',
      data: {openid:app.globalData.openid}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
           _this.setData({shenList:res.data.a})
      }});
  },
  getQiuYuan(){
    var _this=this;
    wx.request({
      url: app.domainName + 'web/?c=getqiuyuan',
      method: 'POST',
      data: {openid:app.globalData.openid}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
           console.log(res);
           _this.setData({qiuList:res.data.a})
      }});
  },
  doyes(e){
    var _id=e.currentTarget.dataset.id;
    this.setYesNo(_id,'yes');
  },
  setYesNo(_id,_type){
    var _this=this;
    wx.request({
      url: app.domainName + 'web/?c=setapplyyesno',
      method: 'POST',
      data: {openid:app.globalData.openid, id:_id,t:_type}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        _this.getShenQing();
      }});
  },
  dono(e){
    var _id=e.currentTarget.dataset.id;
    this.setYesNo(_id,'no');
  },
  tichuqd(e){
    var _this=this;
    var _id=e.currentTarget.dataset.id;
    var _name=e.currentTarget.dataset.name;
    console.log(_id)
    wx.showModal({
      title: '踢出球员',
      content: "您确定踢出："+_name,
      success (res) {
        if (res.confirm) {
          console.log('确定')
          wx.request({
            url: app.domainName + 'web/?c=tichuqy',
            method: 'POST',
            data: {openid:app.globalData.openid, id:_id}, header: { 'content-type': 'application/x-www-form-urlencoded' },
            success: function (res) {
              _this.getQiuYuan();
            }});
        } else if (res.cancel) {
          
        }
      }
    })
  }



})
